package com.zh.spring.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * 描述：com.zh.spring.service
 *
 * @author 80002023
 *         2017/1/3.
 * @version 1.0
 * @since 1.8
 */
@Service
public class ComputeService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "addServiceFallback")
    public String addService() {
        return restTemplate.getForEntity("http://APP-SERVICE/add?a=10&b=202", String.class).getBody();
    }

    public String addServiceFallback() {
        return "error";
    }
}
